﻿/***
 ** 作者:乔迎娜
 ** 日期:2017-1-4
 ** 功能:在线预约
 **/
//页面调用主函数

//var sxbm = "130181ZJ-XK-0002";
var sxbm = "";
var sxmc = "";
var blsx = "";
var blbm = "";
var blck = "";
var lxdh = "";
var zxdh = "";
var sltj = "";
var xm = "";
var sfz = "";
var dh = "";
var dqrq = "";
var yi = "";
var er = "";
var san = "";
var si = "";
var wu = "";
var zy = "";
var ze = "";
var zs = "";
var zsi = "";
var zw = "";
var bllx = "";

var bgNum = 3;//变更可预约人数,20190626日改为3人

$(function () {
    //扩展方法获取url参数  
    $.getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }
    bllx = $.getUrlParam("type");
    if (bllx != "1" && bllx != "2") {
        window.location.href = "wsyy.html";
    }
    //ShowContent();
    ShowMain();
});

function ShowMain() {
    $.ajax({
        url: "action/GetDate.ashx",
        type: "get",
        dataType: 'json',
        data: "{}",
        success: function (data) {
            if (data != "" && data != null) {
                ShowContent();
                if (bllx == "1") {
                    $("#lx").html("企业设立预约")
                } else {
                    $("#lx").html("企业变更预约")
                }
                var datelist = data.h.split(",");
                for (var i = 0; i < datelist.length - 1; i++) {
                    if (i == 0) {
                        $("#yyrq").append("<option selected=\"selected\"  value=\"" + datelist[i] + "\">" + datelist[i] + "</option>");
                    } else {
                        $("#yyrq").append("<option value=\"" + datelist[i] + "\">" + datelist[i] + "</option>");
                    }
                }
                GetYy();
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {

            $('body').dialogBox({
                hasMask: true,
                hasClose: true,
                effect: 'sign',
                hasBtn: true,
                confirmValue: '确定',
                title: '提示',
                content: "数据加载失败!"
            });
        }
    });
}

function GetYy() {
    if ($("#yyrq").val() == "") {
        alert("请选择预约日期");
    } else {
        $.ajax({
            url: "action/GetYy.ashx?yyrq=" + $("#yyrq").val() + "&bllx=" + bllx,
            type: "get",
            dataType: 'json',
            data: "{}",
            success: function (data) {
                var h1 = 0, h2 = 0, h3 = 0, h4 = 0, h5 = 0, h6 = 0, h7 = 0;
                if (data != "" && data != null) {
                    if (data.Table != "" && data.Table != null) {
                        $.each(data.Table, function (i, item) {
                            if (data.Table[i].sjduan == "1h") {
                                h1 = h1 + 1;
                            } else if (data.Table[i].sjduan == "2h") {
                                h2 = h2 + 1;
                            } else if (data.Table[i].sjduan == "3h") {
                                h3 = h3 + 1;
                            } else if (data.Table[i].sjduan == "4h") {
                                h4 = h4 + 1;
                            } else if (data.Table[i].sjduan == "5h") {
                                h5 = h5 + 1;
                            } else if (data.Table[i].sjduan == "6h") {
                                h6 = h6 + 1;
                            } else {
                                h7 = h7 + 1;
                            }
                        });
                        if (bllx == "1") { //企业设立没时段三人  //bllx办理类型
                            if (data.sfdt == "1") {             //data.sfdt是否到期
                                $("#s1h").html("已预约" + h1 + "人");
                                if (h1 == 15) {
                                    $("[type=1h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 9) {        //data.dqrq到期日期
                                        $("[type=1h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'1h\')\">预约</a>")
                                    } else {
                                        $("[type=1h]").html("-")
                                    }
                                }
                                $("#s2h").html("已预约" + h2 + "人");
                                if (h2 == 15) {
                                    $("[type=2h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 10) {
                                        $("[type=2h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'2h\')\">预约</a>")
                                    } else {
                                        $("[type=2h]").html("-")
                                    }
                                }
                                $("#s3h").html("已预约" + h3 + "人");
                                if (h3 == 15) {
                                    $("[type=3h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 11) {
                                        $("[type=3h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'3h\')\">预约</a>")
                                    } else {
                                        $("[type=3h]").html("-")
                                    }
                                }
                                $("#s4h").html("已预约" + h4 + "人");
                                if (h4 == 15) {
                                    $("[type=4h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 13) {
                                        $("[type=4h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'4h\')\">预约</a>")
                                    } else {
                                        $("[type=4h]").html("-")
                                    }
                                }
                                $("#s5h").html("已预约" + h5 + "人");
                                if (h5 == 15) {
                                    $("[type=5h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 14) {
                                        $("[type=5h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'5h\')\">预约</a>")
                                    } else {
                                        $("[type=5h]").html("-")
                                    }
                                }
                                $("#s6h").html("已预约" + h6 + "人");
                                if (h6 == 15) {
                                    $("[type=6h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 15) {
                                        $("[type=6h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'6h\')\">预约</a>")
                                    } else {
                                        $("[type=6h]").html("-")
                                    }
                                }
                                $("#s7h").html("已预约" + h7 + "人");
                                if (h7 == 15) {
                                    $("[type=7h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 16) {
                                        $("[type=7h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'7h\')\">预约</a>")
                                    } else {
                                        $("[type=7h]").html("-")
                                    }
                                }
                            } else {
                                $("#s1h").html("已预约" + h1 + "人");
                                if (h1 == 15) {
                                    $("[type=1h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=1h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'1h\')\">预约</a>")
                                }
                                $("#s2h").html("已预约" + h2 + "人");
                                if (h2 == 15) {
                                    $("[type=2h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=2h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'2h\')\">预约</a>")
                                }
                                $("#s3h").html("已预约" + h3 + "人");
                                if (h3 == 15) {
                                    $("[type=3h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=3h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'3h\')\">预约</a>")
                                }
                                $("#s4h").html("已预约" + h4 + "人");
                                if (h4 == 15) {
                                    $("[type=4h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=4h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'4h\')\">预约</a>")
                                }
                                $("#s5h").html("已预约" + h5 + "人");
                                if (h5 == 15) {
                                    $("[type=5h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=5h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'5h\')\">预约</a>")
                                }
                                $("#s6h").html("已预约" + h6 + "人");
                                if (h6 == 15) {
                                    $("[type=6h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=6h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'6h\')\">预约</a>")
                                }
                                $("#s7h").html("已预约" + h7 + "人");
                                if (h7 == 15) {
                                    $("[type=7h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=7h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'7h\')\">预约</a>")
                                }
                            }
                        } else { //企业变更每时段3人，4号窗口
                            //debugger;
                            //data.sfdt == "1"
                            if (data.sfdt == "1") {
                                $("#s1h").html("已预约" + h1 + "人");
                                if (h1 >= bgNum) {
                                    $("[type=1h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 9) {
                                        $("[type=1h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'1h\')\">预约</a>")
                                    } else {
                                        $("[type=1h]").html("-")
                                    }
                                }
                                $("#s2h").html("已预约" + h2 + "人");
                                if (h2 >= bgNum) {
                                    $("[type=2h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 10) {
                                        $("[type=2h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'2h\')\">预约</a>")
                                    } else {
                                        $("[type=2h]").html("-")
                                    }
                                }
                                $("#s3h").html("已预约" + h3 + "人");
                                if (h3 >= bgNum) {
                                    $("[type=3h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 11) {
                                        $("[type=3h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'3h\')\">预约</a>")
                                    } else {
                                        $("[type=3h]").html("-")
                                    }
                                }
                                $("#s4h").html("已预约" + h4 + "人");
                                if (h4 >= bgNum) {
                                    $("[type=4h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 13) {
                                        $("[type=4h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'4h\')\">预约</a>")
                                    } else {
                                        $("[type=4h]").html("-")
                                    }
                                }
                                $("#s5h").html("已预约" + h5 + "人");
                                if (h5 >= bgNum) {
                                    $("[type=5h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 14) {
                                        $("[type=5h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'5h\')\">预约</a>")
                                    } else {
                                        $("[type=5h]").html("-")
                                    }
                                }
                                $("#s6h").html("已预约" + h6 + "人");
                                if (h6 >= bgNum) {
                                    $("[type=6h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 15) {
                                        $("[type=6h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'6h\')\">预约</a>")
                                    } else {
                                        $("[type=6h]").html("-")
                                    }
                                }
                                $("#s7h").html("已预约" + h7 + "人");
                                if (h7 >= bgNum) {
                                    $("[type=7h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    if (data.dqrq < 16) {
                                        $("[type=7h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'7h\')\">预约</a>")
                                    } else {
                                        $("[type=7h]").html("-")
                                    }
                                }
                            } else {
                                $("#s1h").html("已预约" + h1 + "人");
                                if (h1 >= bgNum) {
                                    $("[type=1h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=1h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'1h\')\">预约</a>")
                                }
                                $("#s2h").html("已预约" + h2 + "人");
                                if (h2 >= bgNum) {
                                    $("[type=2h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=2h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'2h\')\">预约</a>")
                                }
                                $("#s3h").html("已预约" + h3 + "人");
                                if (h3 >= bgNum) {
                                    $("[type=3h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=3h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'3h\')\">预约</a>")
                                }
                                $("#s4h").html("已预约" + h4 + "人");
                                if (h4 >= bgNum) {
                                    $("[type=4h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=4h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'4h\')\">预约</a>")
                                }
                                $("#s5h").html("已预约" + h5 + "人");
                                if (h5 >= bgNum) {
                                    $("[type=5h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=5h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'5h\')\">预约</a>")
                                }
                                $("#s6h").html("已预约" + h6 + "人");
                                if (h6 >= bgNum) {
                                    $("[type=6h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=6h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'6h\')\">预约</a>")
                                }
                                $("#s7h").html("已预约" + h7 + "人");
                                if (h7 >= bgNum) {
                                    $("[type=7h]").html("<font color=\"red\">已约满</font>")
                                } else {
                                    $("[type=7h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'7h\')\">预约</a>")
                                }
                            }
                        }
                    } else {
                        if (data.sfdt == "1") {
                            $("#s1h").html("已预约" + h1 + "人");
                            if (data.dqrq < 9) {
                                $("[type=1h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'1h\')\">预约</a>")
                            } else {
                                $("[type=1h]").html("-")
                            }
                            $("#s2h").html("已预约" + h2 + "人");
                            if (data.dqrq < 10) {
                                $("[type=2h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'2h\')\">预约</a>")
                            } else {
                                $("[type=2h]").html("-")
                            }
                            $("#s3h").html("已预约" + h3 + "人");
                            if (data.dqrq < 11) {
                                $("[type=3h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'3h\')\">预约</a>")
                            } else {
                                $("[type=3h]").html("-")
                            }
                            $("#s4h").html("已预约" + h4 + "人");
                            if (data.dqrq < 13) {
                                $("[type=4h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'4h\')\">预约</a>")
                            } else {
                                $("[type=4h]").html("-")
                            }
                            $("#s5h").html("已预约" + h5 + "人");
                            if (data.dqrq < 14) {
                                $("[type=5h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'5h\')\">预约</a>")
                            } else {
                                $("[type=5h]").html("-")
                            }
                            $("#s6h").html("已预约" + h6 + "人");
                            if (data.dqrq < 15) {
                                $("[type=6h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'6h\')\">预约</a>")
                            } else {
                                $("[type=6h]").html("-")
                            }
                            $("#s7h").html("已预约" + h7 + "人");
                            if (data.dqrq < 16) {
                                $("[type=7h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'7h\')\">预约</a>")
                            } else {
                                $("[type=7h]").html("-")
                            }
                        } else {
                            $("#s1h").html("已预约" + h1 + "人");
                            $("[type=1h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'1h\')\">预约</a>")
                            $("#s2h").html("已预约" + h2 + "人");
                            $("[type=2h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'2h\')\">预约</a>")
                            $("#s3h").html("已预约" + h3 + "人");
                            $("[type=3h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'3h\')\">预约</a>")
                            $("#s4h").html("已预约" + h4 + "人");
                            $("[type=4h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'4h\')\">预约</a>")
                            $("#s5h").html("已预约" + h5 + "人");
                            $("[type=5h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'5h\')\">预约</a>")
                            $("#s6h").html("已预约" + h6 + "人");
                            $("[type=6h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'6h\')\">预约</a>")
                            $("#s7h").html("已预约" + h7 + "人");
                            $("[type=7h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'7h\')\">预约</a>")
                        }
                    }
                } else {
                    $("#s1h").html("已预约" + h1 + "人");
                    $("[type=1h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'1h\')\">预约</a>")
                    $("#s2h").html("已预约" + h2 + "人");
                    $("[type=2h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'2h\')\">预约</a>")
                    $("#s3h").html("已预约" + h3 + "人");
                    $("[type=3h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'3h\')\">预约</a>")
                    $("#s4h").html("已预约" + h4 + "人");
                    $("[type=4h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'4h\')\">预约</a>")
                    $("#s5h").html("已预约" + h5 + "人");
                    $("[type=5h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'5h\')\">预约</a>")
                    $("#s6h").html("已预约" + h6 + "人");
                    $("[type=6h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'6h\')\">预约</a>")
                    $("#s7h").html("已预约" + h7 + "人");
                    $("[type=7h]").html("<a href=\"javascript:void(0)\" onclick=\"operate(\'1\',\'\',\'7h\')\">预约</a>")
                }
                $("#sjlb0").hide();
                $("#sjlb").show();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {

                $('body').dialogBox({
                    hasMask: true,
                    hasClose: true,
                    effect: 'sign',
                    hasBtn: true,
                    confirmValue: '确定',
                    title: '提示',
                    content: "数据加载失败!"
                });
            }
        });
    }
};

function fz(flg) {
    document.getElementById("sqrlx").value = flg;
}

function fz_yw(flg) {
    document.getElementById("ywlx").value = flg;
}


function ShowContent() {
    var str = "";
    str += '    <form id="formsubmit">';
    str += '        <input type="hidden" id="sxbm" name="sxbm" value="' + sxbm + '" />';
    str += '        <input type="hidden" id="yuyuesj" name="yuyuesj" />';
    str += '        <input type="hidden" id="sqrlx" name="sqrlx" value="2" />';

    str += '        <input type="hidden" id="ywlx" name="ywlx" value="1" />';

    str += '    <div class="weui_tab">';
    str += '    <div class="weui_tab_bd">';
    str += '        <div class="weui_cells weui_cells_form">';
    str += '            <div class="weui_cell">';
    str += '                <div class="weui_cell_hd "><label for="" class="weui_label"><span class="red">* </span>预约日期</label></div>';
    str += '                <div class="weui_cell_bd weui_cell_primary">';
    str += '                    <select name="yyrq" id="yyrq" onchange="GetYy()">';
    str += '                    <option selected="selected" value="">--请选择预约日期--</option>';
    str += '                    </select>';
    str += '                </div>';
    str += '            </div>';
    if (bllx == "1") {
        str += '            <div class="weui_cell">';
        str += '                <div class="weui_cell_hd "><label for="" class="weui_label"><span class="red">* </span>预约日期</label></div>';
        str += '                <div class="weui_cell_bd weui_cell_primary">';
        str += '                    <select name="blwd" id="blwd" onchange="Getbldz()">';
        str += '                    <option selected="selected" value="">--请选择办理网点--</option>';
        str += '                    <option value="裕华西路85号">--农行西城支行--</option>';
        str += '                    <option value="友谊南大街23号">--农行和平支行--</option>';
        str += '                    <option value="工农路558号">--农行西环路支行--</option>';
        str += '                    <option value="友谊南大街122号">--农行友谊南支行--</option>';
        str += '                    <option value="新石中路375号">--农行新石中支行--</option>';
        str += '                    </select>';
        str += '                </div>';
        str += '            </div>';
        str += '            <div class="weui_cell">';
        str += '                <div class="weui_cell_hd"><label class="weui_label"><span class="red">* </span>办理地址</label></div>';
        str += '                <div class="weui_cell_bd weui_cell_primary">';
        str += '                    <input class="weui_input" type="text" id="bldz" name="bldz"/>';
        str += '                </div>';
        str += '            </div>';
    }
    str += '            <div class="weui_cell">';
    str += '                <div class="weui_cell_hd"><label class="weui_label"><span class="red">* </span>企业名称</label></div>';
    str += '                <div class="weui_cell_bd weui_cell_primary">';
    str += '                    <input class="weui_input" type="text" id="qymc" name="qymc" placeholder="请输入企业名称"/>';
    str += '                </div>';
    str += '            </div>';

    if (bllx == "2") {
        str += '            <div class="weui_cell">';
        str += '                <div class="weui_cell_hd"><label class="weui_label"><span class="red">* </span>业务类型</label></div>';
        str += '                <div class="weui_cell_bd weui_cell_primary">';
        str += '                    <input type="radio" id="yw1" name="yw" value="1" onclick="fz_yw(\'1\')" checked/>变更 &nbsp;  ';
        str += '                    <input type="radio" id="yw2" name="yw" value="2" onclick="fz_yw(\'2\')"/> 注销';
        str += '                </div>';
        str += '            </div>';
    }

    str += '            <div class="weui_cell">';
    str += '                <div class="weui_cell_hd"><label class="weui_label"><span class="red">* </span>申请人类型</label></div>';
    str += '                <div class="weui_cell_bd weui_cell_primary">';
    str += '                    <input type="radio" id="xz1" name="xz" value="1" onclick="fz(\'1\')"/>个人 &nbsp; <input type="radio" id="xz2" name="xz" value="2" onclick="fz(\'2\')" checked/> 代办';
    //str += '                    <select name="sqrlx" id="sqrlx">';
    //str += '                    <option selected="selected" value="">--请选择类型--</option>';
    //str += '                    <option value="1">--个人--</option>';
    //str += '                    <option value="2">--代办--</option>';
    //str += '                    </select>';
    str += '                </div>';
    str += '            </div>';

    str += '            <div class="weui_cell">';
    str += '                <div class="weui_cell_hd"><label class="weui_label"><span class="red">* </span>身份证号</label></div>';
    str += '                <div class="weui_cell_bd weui_cell_primary">';
    str += '                    <input class="weui_input" type="text" id="sfz" name="sfz" placeholder="请输入身份证号码"/>';
    str += '                </div>';
    str += '            </div>';
    str += '            <div class="weui_cell">';
    str += '                <div class="weui_cell_hd">';
    str += '                  <label class="weui_label"><span class="red">* </span>手机号码</label></div>';
    str += '                <div class="weui_cell_bd weui_cell_primary">';
    str += '                    <input class="weui_input" type="number" id="sjh" name="sjh" pattern="[0-9]*" placeholder="请输入手机号码"/>';
    str += '                </div>';
    str += '            </div>';
    str += '            <div class="weui_cell">';
    str += '                <div class="weui_cell_hd"><label class="weui_label"><span class="red">* </span>代办公司</label></div>';
    str += '                <div class="weui_cell_bd weui_cell_primary">';
    str += '                    <input class="weui_input" type="text" id="dbmc" name="dbmc" placeholder="请输入代办公司名称"/>';
    str += '                </div>';
    str += '            </div>';
    str += '            </div>';
    str += '        <div class="weui_cell" style="padding: 0;">';
    str += '                <div class="applicant-info"><div class="bespeak mt10">';
    str += '                    <table id="tbYYList" class="make-appointment">';
    str += '                        <thead>';
    str += '                        <tr id="tr_0">';
    str += '                            <th id="th_0"><span>上午</span><span></span></th>';
    str += '                            <th id="th_1" type="2017-06-23">预约</th>';
    str += '                            <th id="th_2" type="2017-06-26"><span>下午</span><span></span></th>';
    str += '                            <th id="th1" type="2017-06-26">预约</th>';
    str += '                          </tr>';
    str += '                        </thead>';
    str += '                        <tbody id="sjlb" style="display:none">';
    str += '                        <tr id="tr_1">';
    str += '                            <td class="left-time" id="td_0" type="830">';
    str += '                                <span>9:00~</span>';
    str += '                                <span>10:00</span>';
    str += '                                      <br/>';
    str += '                                <sapn id="s1h">已预约0人</span>';
    str += '                            </td>';
    str += '                            <td id="td_1" type="1h">';
    str += '                                <a href="javascript:void(0)" onclick="operate(\'1\',\'\',\'1h\')">预约</a>';
    str += '                                <span class="hidden"></span>';
    str += '                                <i class="hidden"></i>';
    str += '                            </td>';
    str += '                            <td class="left-time" id="td1" type="830"><span>14:00~</span> <span>15:00</span>';
    str += '                                      <br/>';
    str += '                                <sapn id="s4h">已预约0人</span>';
    str += '                              </td>';
    str += '                            <td id="td_2" type="4h"><a href="javascript:void(0)" onclick="operate(\'1\',\'\',\'4h\')">预约</a> <span class="hidden"></span> <i class="hidden"></i></td>';
    str += '                          </tr>';
    str += '                            <tr id="tr_2">';
    str += '                            <td class="left-time" id="td2" type="1000">';
    str += '                                <span>10:00~</span>';
    str += '                                <span>11:00</span>';
    str += '                                      <br/>';
    str += '                                <sapn id="s2h">已预约0人</span>';
    str += '                            </td>';
    str += '                            <td id="td3" type="2h">';
    str += '                                <a href="javascript:void(0)" onclick="operate(\'1\',\'\',\'2h\')">预约</a>';
    str += '                                <span class="hidden"></span>';
    str += '                                <i class="hidden"></i>';
    str += '                            </td>';
    str += '                            <td class="left-time" id="td4" type="1000"><span>15:00~</span> <span>16:00</span>';
    str += '                                      <br/>';
    str += '                                <sapn id="s5h">已预约0人</span>';
    str += '                              </td>';
    str += '                            <td id="td5" type="5h"><a href="javascript:void(0)" onclick="operate(\'1\',\'\',\'5h\')">预约</a> <span class="hidden"></span> <i class="hidden"></i></td>';
    str += '                          </tr>';
    str += '                        <tr id="tr_3">';
    str += '                            <td class="left-time" id="td7" type="1330">';
    str += '                                <span>11:00~</span>';
    str += '                                <span>12:00</span>';
    str += '                                      <br/>';
    str += '                                <sapn id="s3h">已预约0人</span>';
    str += '                            </td>';
    str += '                            <td id="td8" type="3h">';
    str += '                                <a href="javascript:void(0)" onclick="operate(\'1\',\'\',\'3h\')">预约</a>';
    str += '                                <span class="hidden"></span>';
    str += '                                <i class="hidden"></i>';
    str += '                            </td>';
    str += '                            <td id="td9" type="1330" class="left-time"><span>16:00~</span> <span>17:00</span>';
    str += '                                      <br/>';
    str += '                                <sapn id="s6h">已预约0人</span>';
    str += '                              </td>';
    str += '                            <td id="td6" type="6h"><a href="javascript:void(0)" onclick="operate(\'1\',\'\',\'6h\')">预约</a> <span class="hidden"></span> <i class="hidden"></i></td>';
    str += '                          </tr>';
    str += '                        <tr id="tr_4">';
    str += '                            <td class="left-time" id="td11" type="1430">-';
    str += '                            </td>';
    str += '                            <td id="td12" type="2017-06-23_1430">-';
    str += '                            </td>';
    str += '                            <td id="td13" type="1430" class="left-time"><span>17:00~</span> <span>18:00</span>';
    str += '                                      <br/>';
    str += '                                <sapn id="s7h">已预约0人</span>';
    str += '                              </td>';
    str += '                            <td id="td10" type="7h"><a href="javascript:void(0)" onclick="operate(\'1\',\'\',\'7h\')">预约</a> <span class="hidden"></span> <i class="hidden"></i></td>';
    str += '                          </tr>';
    str += '                        </tbody>';
    str += '                        <tbody id="sjlb0"><tr><td colspan="4"><font color="red">请选择预约日期</font></td></tr></tbody>         ';
    str += '                    </table>';
    str += '              </div></div>';
    str += '            </div>';
    str += '    </div>';
    str += '    <div class="weui_tabbar">';
    str += '        <a href="javascript:;" class="weui_btn weui_btn_blue" id="showToast" onclick="SubMitUser();">提交</a>';
    str += '    </div>';
    str += '    <div id="toast" style="display:none;">';
    str += '        <div class="weui_mask_transparent"></div>';
    str += '        <div class="weui_toast">';
    str += '            <i class="weui_icon_toast"></i>';
    str += '            <p class="weui_toast_content">预约成功</p>';
    str += '        </div>';
    str += '    </div>';
    str += '</div>';
    str += '</form>';
    $("#StrContent").html(str);
}

var NID;

//----------------选择预约时间-----------------
function operate(type, message, nid) {

    if (type == "0") {
        alert(message);
        return false;
    } else if (type == "1")
        choseApp(nid);
    else
        showDetail(nid);
}

function showDetail(nid) {
}

function choseApp(nid, choseAppinfo) {
    //首先，先将其他已选择去掉
    $("#tbYYList").find("td").each(function () {
        if ($(this).hasClass("scur")) {
            $(this).removeClass("scur");
            $(this).children("i").addClass("hidden");
            if ($(this).children("a").text() == "已选择")
                $(this).children("a").text("预约");
        }

    })
    NID = nid;
    $("[type=" + nid + "]").children("a").text("已选择");
    $("[type=" + nid + "]").addClass("scur");
    $("[type=" + nid + "]").children("i").removeClass("hidden");
    $("[type=" + nid + "]").children("i").one("click", function () {
        cancelApp("1", nid);
    })
}

//---------------------------------------------

//---------------删除预约----------------------
function cancelApp(type, nid, id) {
    //type表示操作类型，1表示去除表面的样式，2表示删除预约记录
    if (type == "1") {
        $("[type=" + nid + "]").children("a").text("预约");
        $("[type=" + nid + "]").removeClass("scur");
        $("[type=" + nid + "]").children("i").addClass("hidden");
        NID = null;
    } else if (type = "2") {
        $.ajax({
            url: "../action/zhuce/yysc.ashx?id=" + id + "&flg=1",    //后台webservice里的方法名称                                   
            type: "post",
            dataType: 'json',
            data: "{}",
            success: function (data) {
                if (data == true) {
                    //isLogin();
                } else {
                    //ShowMain();
                    alert("取消成功");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $('body').dialogBox({
                    hasMask: true,
                    hasClose: true,
                    effect: 'sign',
                    hasBtn: true,
                    confirmValue: '确定',
                    title: '提示',
                    content: "数据加载失败!"
                });
            }
        });
    }
}

//---------------------------------------------

function yincang() {
    $("#xie").css('display', 'none');
    $("#content1").css('display', 'none');
    $("#content1").html("");
}

function goBack() {
    history.go(-1);
}

function Getbldz() {
    if (document.getElementById("blwd").value == "") {
        alert("请选择办理网点");
        document.getElementById("bldz").value = "";
    } else {
        document.getElementById("bldz").value = document.getElementById("blwd").value;
    }
}

function SubMitUser() {
    if (CheckForm()) {
        if (submitApp()) {
            if (confirm("请您再次核对公司名称，确认提交！")) {
                $.ajax({
                    url: "action/yysave.ashx?Type=" + bllx,    //后台webservice里的方法名称                                   
                    type: "post",
                    dataType: 'json',
                    data: $('#formsubmit').serialize(),
                    success: function (data) {
                        if (data == "1") {
                            alert("您选择的该时段已达预约上限");
                        } else if (data == "2") {
                            alert("您已经在当前预约日期预约业务");
                        } else {
                            $("#toast").show();
                            setTimeout("goBack()", 3000);
                        }
                        //history.go(-1);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $('body').dialogBox({
                            hasMask: true,
                            hasClose: true,
                            effect: 'sign',
                            hasBtn: true,
                            confirmValue: '确定',
                            title: '提示',
                            content: "数据加载失败!"
                        });
                    }
                });
            }
        }
    }
}

function CheckForm() {
    if (document.getElementById("yyrq").value == "") {
        alert("请选择预约日期！");
        //document.getElementById("yyrq").focus();
        return false;
    }
    if (bllx == "1") {
        if (document.getElementById("blwd").value == "") {
            alert("请选择办理网点！");
            //document.getElementById("qymc").focus();
            return false;
        }
    }
    if (document.getElementById("qymc").value == "") {
        alert("请输入企业名称！");
        document.getElementById("qymc").focus();
        return false;
    }
    if (document.getElementById("sqrlx").value == "") {
        alert("请选择预约人类型！");
        //document.getElementById("qymc").focus();
        return false;
    }
    if (document.getElementById("sfz").value == "") {
        alert("请输入身份证号码！");
        document.getElementById("sfz").focus();
        return false;
    }
    var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
    if (reg.test(document.getElementById("sfz").value) === false) {
        alert("身份证号码不合法");
        return false;
    }
    if (document.getElementById("sjh").value == "") {
        alert("请输入手机号码！");
        document.getElementById("sjh").focus();
        return false;
    }
    if (document.getElementById("sqrlx").value == "2" && document.getElementById("dbmc").value == "") {
        alert("请输入代办公司名称！");
        document.getElementById("dbmc").focus();
        return false;
    }
    return true;
}

function getDayofWeek(str) {
    var xq = str.replace(/-/g, "/");
    var day = "";
    var time = new Date(xq);
    var numOfWeek = time.getDay();
    switch (numOfWeek) {
        case 0:
            day = "星期日";
            break;
        case 1:
            day = "星期一";
            break;
        case 2:
            day = "星期二";
            break;
        case 3:
            day = "星期三";
            break;
        case 4:
            day = "星期四";
            break;
        case 5:
            day = "星期五";
            break;
        case 6:
            day = "星期六";
            break;
    }

    return day;
}

function submitApp() {
    if (NID == null) {
        alert("请选择预约时段");
        return false;
    } else {
        //赋值
        document.getElementById("yuyuesj").value = NID;
        var t = NID.split('_')[0];
        var tSpan = NID.split('_')[1];
        var AppTime = $("[type=" + t + "]").children().last().text() + "日" + $("[type=" + tSpan + "]").children().first().text() + $("[type=" + tSpan + "]").children().last().text();
        return true;
    }
}
